package com.intelligentcar.springboot.controller;

import com.intelligentcar.springboot.bean.ImitateRide;
import com.intelligentcar.springboot.service.ImitateRideServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

@Controller
public class ImitateRideController {
    @Autowired
    private ImitateRideServer imitateRideServerImpl;

    // 新增高峰期
    @RequestMapping("/addpeak")
    @ResponseBody
    public Map addpeak(@RequestBody ImitateRide imitateRide) {
        Map map = new HashMap();
        map.put("code", imitateRideServerImpl.addpeak(imitateRide));
        return map;
    }

    //新增高峰期站点
    @RequestMapping("/addpeak1")
    @ResponseBody
    public Map addpeak1(@RequestBody ImitateRide imitateRide) {
        Map map = new HashMap();
        map.put("code", imitateRideServerImpl.addpeak1(imitateRide));
        return map;
    }
    //新增高峰期时间段和站点
    @RequestMapping("/addpeak2")
    @ResponseBody
    public Map addpeak2(@RequestBody ImitateRide imitateRide) {
        Map map = new HashMap();
        map.put("code", imitateRideServerImpl.addpeak2(imitateRide));
        return map;
    }
    //模拟乘车
    @RequestMapping("/Ride")
    @ResponseBody
    public Map Ride(@RequestBody ImitateRide imitateRide) {
        Map map = new HashMap();

        ImitateRide imitateRide1 = imitateRideServerImpl.celectImitateRide(imitateRide);
        if(imitateRide1!=null){
            map.put("num", 1);
        }
        ImitateRide imitateRide2 = imitateRideServerImpl.celectImitateRide1(imitateRide);
        if(imitateRide2!=null){
            map.put("num1", 1);
        }
        return map;
    }
}
